# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

cmake_minimum_required(VERSION 3.13)

# Project
project(onnxruntime_samples C CXX)
if (WIN32)
 string(APPEND CMAKE_CXX_FLAGS " /W4")
else()
 string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
 string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
endif()

#onnxruntime providers
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_NNAPI "Build with DNNLibrary for Android NNAPI support" OFF)
option(onnxruntime_USE_MKLDNN "Build with MKL-DNN support" OFF)
option(onnxruntime_USE_NGRAPH "Build with nGraph support" OFF)
option(onnxruntime_USE_NUPHAR "Build with Nuphar" OFF)
option(onnxruntime_USE_BRAINSLICE "Build with BrainSlice" OFF)
option(onnxruntime_USE_TENSORRT "Build with TensorRT support" OFF)
option(LIBPNG_ROOTDIR "libpng root dir")

#if JPEG lib is available, we'll use it for image decoding, otherwise we'll use WIC
find_package(JPEG)
if(LIBPNG_ROOTDIR)
  set(PNG_FOUND true)
  if(WIN32)
    set(PNG_LIBRARIES debug libpng16_d optimized libpng16)
  else()
    set(PNG_LIBRARIES png16)
  endif()
  set(PNG_INCLUDE_DIRS "${LIBPNG_ROOTDIR}/include")
  set(PNG_LIBDIR "${LIBPNG_ROOTDIR}/lib")
else()
  find_package(PNG)
endif()

if(onnxruntime_USE_CUDA)
  add_definitions(-DUSE_CUDA)
endif()
if(onnxruntime_USE_OPENVINO)
  add_definitions(-DUSE_OPENVINO)
endif()
if(onnxruntime_USE_NNAPI)
  add_definitions(-DUSE_NNAPI)
endif()
if(onnxruntime_USE_NNAPI)
  add_definitions(-DUSE_NNAPI)
endif()
if(onnxruntime_USE_MKLDNN)
  add_definitions(-DUSE_MKLDNN)
endif()
if(onnxruntime_USE_NGRAPH)
  add_definitions(-DUSE_NGRAPH)
endif()
if(onnxruntime_USE_NUPHAR)
  add_definitions(-DUSE_NUPHAR)
endif()
if(onnxruntime_USE_BRAINSLICE)
  add_definitions(-DUSE_BRAINSLICE)
endif()
if(onnxruntime_USE_TENSORRT)
  add_definitions(-DUSE_TENSORRT)
endif()

#TODO: remove this part(need to talk to Ryan and find a solution for this)
if(UNIX)
 include_directories("/usr/local/include/onnxruntime")
else()
 include_directories("C:\\Program Files (x86)\\onnxruntime\\include" "C:\\Program Files (x86)\\onnxruntime\\include\\onnxruntime" "C:\\Program Files (x86)\\onnxruntime\\include\\onnxruntime\\core\\session")
 link_directories("C:\\Program Files (x86)\\onnxruntime\\lib")
endif()


add_subdirectory(imagenet)
if(PNG_FOUND)
  add_subdirectory(fns_candy_style_transfer)
endif()
add_subdirectory(MNIST)
